<?php
/**
 * Created by PhpStorm.
 * Muser: lvchy
 * Date: 2018/9/26
 * Time: 16:48
 */

namespace app\common\model;
use think\Model;
use traits\model\SoftDelete;

class SysUser extends Model
{
    use SoftDelete;
// 设置完整的数据表（包含前缀）
    protected $table = 'sys_user';

    protected $deleteTime = 'delete_time';

//    protected $hidden=['password'];

    /**
     * 查看用户详情
     * @param $con
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function get_user_detail($con){
        if(empty($con)) return;  //条件为空不查询， 防止差错
        $field = "open_id,user_id,phone,service_openid,nick_name,sex,phone,true_name,state,station_id,station_name,auth_type";
        $data = $this->field($field)->where($con)->find();
        return $data;
    }

    public function company(){
        return $this->belongsTo('SalesCompany', 'company_id', 'id')->bind('company_name');
    }
    public function role(){
        return $this->belongsTo('Role', 'role_id', 'role_id')->bind('role_name');
    }
    public function get_driver_detail($con){
        if(empty($con)) return;  //条件为空不查询， 防止差错
        $field = "user_id,true_name,phone,user_type,company_id";
        $data = $this->field($field)->where($con)->find();
        return $data;
    }
}